#pragma once

#include <vector>
#include "../Utilities/utilities.h"
#include "Defines.h"

class cShader;

class cVideoDriver
{
protected:
	static cVideoDriver	*ms_Instance;

	GLuint	m_FBOProgram;
	GLuint	m_aFBOColor[FBO_MAX_INDEX];
	GLuint	m_aFBODepth[FBO_MAX_INDEX];

	Vector2 aVertices[4];

	cVideoDriver();
	cVideoDriver(const cVideoDriver &) { }
	cVideoDriver& operator =(const cVideoDriver &) { }
	virtual ~cVideoDriver();

public:
	enum {
		PPE_FBO = 0,
		PPE_BLACK_AND_WHITE,
		PPE_BLUR,
		PPE_BLOOM,
		PPE_DEPTH_OFF_FIELD,
	};

	int		m_typeEffect;

	cShader	*m_pFBOShader;
	cShader	*m_pFBOBlackAndWhiteShader;
	cShader	*m_pFBOBlurShader;
	cShader	*m_pFBOPreBloomShader;
	cShader	*m_pFBOBloomShader;
	cShader	*m_pFBODOFShader;

	static cVideoDriver* GetInstance();
	static void DestroyInstance();

	void Init();

	void SetFBO(int fboIndex);
	void StopFBO();

	void DrawFBO(int fboIndex, int colorIndex);
	void DrawBlackAndWhite(int fboIndex, int colorIndex);
	void DrawBlur(int fboIndex, int colorIndex, float k);
	void DrawPreBloom(int fboIndex, int colorIndex, float limit);
	void DrawBloom(int fboIndex, int colorIndex, int colorIndex2);
	void DrawDepthOfField(int fboIndex, int colorIndex, int colorIndex2, int depthIndex, float saturation);

	void DrawPostProcessingEffects(int fboStartIndex);
};
